<?php
class view {
    var $scripts;
    var $data;
    var $title;


    public static function load($meno, $data = array()) {
        $subor = './view/' . $meno . '.php';
        $trieda = 'v' . $meno;
        include($subor);
        return new $trieda($data);
    }
                
    /* Konstruktor */
    public function __construct($data) {
        $this->data = $data;
		
    }
    
    /* Generovanie HTTP hlaviciek */
    /* Pomocou tejto metody mozeme mat view,
       ktore sposobi presmerovanie (view/redirect.php)
       alebo vytvori chybovu stranku so spravnym statusom (view/error404.php) */
    public function http_headers() {
		
    }

    /* Vygenerovanie dodatocnych elementov v hlavicke HTML */
    public function head() {
                $this->show_scripts();
    }
    
    /* Vypis obsahu elementu title */
    public function title() {
                echo $this->title;
    }
    
    /* Vypis do hlavneho stlpca */
    public function main() {
                echo "";
    }
    
    /* Vypis do praveho stlpca */
        public function right() {
                echo "Right content for this view";
    }
    
    protected function show_scripts() {
                if (!(isset($this->scripts))||($this->scripts=="")){}
                else {          
                        foreach($this->scripts as $script) {
                                echo "<script type=\"text/javascript\" src='/javascript/".$script."'></script> \n";
                        }
                }
    }
        
}